<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="huoyun" uri="/huoyun"%>
<%@ taglib uri="/struts-tags" prefix="s"%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<title>发布车源信息</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">

<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/theme/css/main.css">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/theme/css/style_userCenter.css">
<script type="text/javascript" src="${pageContext.request.contextPath}/theme/js/jquery-1.6.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/car/js/jarea-by-chengxin.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/theme/js/calendar/WdatePicker.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/theme/js/additional-methods.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/car/js/publish-car-tzh.js"></script>

<script type="text/javascript">
	function add_event(e) {
		e.onmouseover = function() {
			e.className += ' hover';
		};
		e.onmouseout = function() {
			e.className = e.className.replace(' hover', '');
			e.className = e.className.replace(' active', '');
		};
		e.onmousedown = function() {
			e.className = e.className.replace(' hover', ' active');
		};
		e.onmouseup = function() {
			e.className = e.className.replace(' active', ' hover');
		};
	}
	
	/*
		切换是否整车时的网页端界面
	*/
	function switchType()
	{
		var type = $("input[name='carPubInfo.type']:checked").val();
		if (type == 0)
		{
			$("#un_total_div").slideToggle('fast');
		}
		else if (type == 1)
		{
			$("#un_total_div").slideToggle('fast');
		}
	}

	window.onload = function() {
		var button = document.getElementById('submit_button');
		add_event(button);
		
		var type = $("input[name='carPubInfo.type']:checked").val();
		if (type == 1)
		{
			$("#un_total_div").show();
		}
		else if (type == 1)
		{
			$("#un_total_div").hide();
		}
	};
</script>

<style type="text/css">
#submit_button {
	width: 100px;
	height: 40px;
	background-image:
		url("${pageContext.request.contextPath}/theme/images/button_normal.png");
	background-size: 100% 100%;
	border: none;
	cursor: pointer;
	font-family: 宋体;
	font-size: 18px;
	font-style: normal;
	color: #fff;
	font-weight: bold;
	background-image:
		url("${pageContext.request.contextPath}/theme/images/button_normal_ie.png")
		\9;
}

#submit_button:hover,#submit_button.hover {
	background-image:
		url("${pageContext.request.contextPath}/theme/images/button_hover.png");
	background-image:
		url("${pageContext.request.contextPath}/theme/images/button_hover_ie.png")
		\9;
}

#submit_button:active,#submit_button.active {
	background-image:
		url("${pageContext.request.contextPath}/theme/images/button_down.png");
	background-image:
		url("${pageContext.request.contextPath}/theme/images/button_down_ie.png")
		\9;
}

#my_offline_cars_div table {
	width: 100%;
	border-collapse: collapse;
	border-bottom: 1px solid #666;
}

#my_offline_cars_div table th{
	color: #333;
	padding: 3px;
	font-family: monospace;
	background: #9cf;
	text-align: left;
	border-top: 1px solid #666;
	border-bottom: 1px solid #666;
	text-align: center;
}

#my_offline_cars_div table td {
	padding: 3px;
	border-top: 1px solid #ccc;
	text-align: center;
}

.red {
	color: red;
}
</style>

</head>

<body>
	<div>
		<jsp:include page="../userAdmin/nav.jsp">
			<jsp:param value="nav_main" name="nav" />
		</jsp:include>
	</div>
	<div class="realCer">

		<!--主体部分-->
		<div class="realMain clearfix mt10">
			<!--左侧菜单-->
			<div class="realLeft" id="meunLeft">
				<jsp:include page="../userAdmin/leftMenu.jsp">
					<jsp:param value="con_nav_main" name="con_nav" />
					<jsp:param value="prePublishCar" name="selectMenu"/>
				</jsp:include>
			</div>
			<!--中间-->
			<div class="realRight ml10">
				<!--中间-->
				<div class="realR_left">
					<div class="box" style="width:805px;">
						<div class="tit">
							<strong>发布新的车源</strong>
						</div>
						<div class="con">
							<%-- <div id="error_div">
								<strong><font size="4px"><span class="red">注意：</span>加<span
										class="red">*</span>号项为必填项！</font>
								</strong><br>
								<br> <span id="error_mark"><img
									src="/huoyun/car/images/error.gif" />&nbsp;&nbsp;</span><span
									id="hint" style="color:#e6352a"></span>
							</div> --%>
							<br>
							<div class="form_wrap clearfix">
								<div style="color: red; margin-left: 100px;">
									<s:property value="resultMsg" />
									<s:fielderror></s:fielderror>
								</div>
								<s:if test="carList.isEmpty()">
									<script type="text/javascript">
										$("#error_div").hide();
									</script>
									<div style="width:100%; text-align:center;">
										<p>
											<strong><font size="5">您没有多余的车辆用来发布新的车源信息！</font>
											</strong>
										</p>
										<p>
											<font size="2">（如果要发布新的车源，请先删除无用的车源信息，或者注册新的车辆。）</font> <br> <font
												size="2">（您可以在</font><a
												href="<s:url action="showMyPublishedCars.action" namespace="/car"></s:url>">车源管理</a><font
												size="2">中删除无用的车源信息，或者修改下面未上线的车源信息并重新发布。）</font>
										</p>
									</div>
								</s:if>
								<s:else>
									<script type="text/javascript">
										$("#error_div").show();
									</script>
									<form style="left:40px; position:relative;" method="post" name="carInfo" action="${pageContext.request.contextPath}/car/pubCarInfo.action">
										<table id="publish_car_table1" cellpadding="5px">
											<!-- 车牌号 -->
											<tr>
												<td width="100" id="xx1"><span class="red">* </span>车牌号：</td>
												<td id="number_td">
													<s:select id="carDetailID" name="carPubInfo.carId"
														list="carList" listKey="id" listValue="cardNumber"
														headerKey="-1" headerValue="-请选择已有车辆-" emptyOption="false"
														multiple="false" theme="simple">
													</s:select> &nbsp;&nbsp;&nbsp;&nbsp; <a
													href="${pageContext.request.contextPath}/car/selectRegCarMethod.action">注册新车辆</a>
												</td>
											</tr>
											<!-- 起始地 -->
											<tr>
												<td id="xx2"><span class="red">* </span>运载路线：</td>
												<td id="AreaA">
													<huoyun:regionSelect provinceName="carRouteA.startProvince" cityName="carRouteA.startCity" townName="carRouteA.startTown" />
													&nbsp;到&nbsp;
													<huoyun:regionSelect provinceName="carRouteA.endProvince" cityName="carRouteA.endCity" townName="carRouteA.endTown"/>
													<a href="javascript:;" id="addAreaHref">添加路线</a>
												</td>
											</tr>
											<tr id="Area2" style="display:none;">
												<td id="xx2"><span class="red">* </span></td>
												<td id="AreaB">
													<huoyun:regionSelect provinceName="carRouteB.startProvince" cityName="carRouteB.startCity" townName="carRouteB.startTown" />
													&nbsp;到&nbsp;
													<huoyun:regionSelect provinceName="carRouteB.endProvince" cityName="carRouteB.endCity" townName="carRouteB.endTown"/>	
													<a href="javascript:;" id="deleteAreaHref2">删除</a>
												</td>
											</tr>
											<tr id="Area3" style="display:none;">
												<td id="xx2"><span class="red">* </span></td>
												<td id="AreaC">
													<huoyun:regionSelect provinceName="carRouteC.startProvince" cityName="carRouteC.startCity" townName="carRouteC.startTown" />
													&nbsp;到&nbsp;
													<huoyun:regionSelect provinceName="carRouteC.endProvince" cityName="carRouteC.endCity" townName="carRouteC.endTown"/>
													<a href="javascript:;" id="deleteAreaHref3">删除</a>
												</td>
											</tr>
										</table>
											
											
										<table>
											<!-- 发车时间区间 -->
											<tr>
												<td id="td1width"><span class="red">* </span>发车时间区间：</td>
												<td>
												<input type="text" name="carPubInfo.starttime" id="fromDate" class="Wdate" style="width:180px" />
												 到 
												<input type="text" name="carPubInfo.endtime" id="toDate" class="Wdate" style="width:180px" /></td>
											</tr>
											<!-- 最大可载吨位 -->
											<tr>
												<td width="100"><span class="red">* </span>额定载重量：</td>
												<td id="loadMaxTd">
													<s:textfield id="loadMax" name="loadMax" disabled="true" theme="simple" />
													<span>吨</span>
												</td>
											</tr>
											
											<tr>
												<td><span class="red">* </span>是否整车运输：</td>
												<td><s:radio id="carPubInfo.type" list="#{'0':'是','1':'否'}" name="carPubInfo.type" value="0" onclick="switchType();" theme="simple"/></td>
											</tr>
										</table>
											
										<div id="un_total_div" style="display:none;">
											<table>
												<!-- 可运载货物数量 -->
												<tr>
													<td><span class="red">* </span>可运载重量：</td>
													<td id="loadAmountTd">
														<s:textfield id="loadAmount" name="carPubInfo.loadAmount" theme="simple" />
														<huoyun:customSelect mode="measureType" name="carPubInfo.unit" />
													</td>
												</tr>
												<!-- 附加说明 -->
												<tr>
													<td style="width:100px; vertical-align:text-top;">
														附加说明(选填)：
													</td>
													<td id="otherInfoTd">
														<s:textarea id="otherInfo" name="carPubInfo.otherInfo" theme="simple" rows="5" cols="70"></s:textarea>
														<br>（您可以填写车辆中已有货物的描述信息，这样货主会更容易选择您的车辆哦~）
													</td>
												</tr>
											</table>
										</div>
											
										<table>
											<!-- 默认联系方式 -->
											<tr>
												<td width="100">默认联系方式：</td>
												<td>
													<s:textfield id="defaultContactDisplay" disabled="true" theme="simple"/>
													<s:textfield id="defaultContactCommitted" name="carPubInfo.defaultContact" style="display:none;" theme="simple"/>
												</td>
											</tr>
											<!-- 紧急联系方式 -->
											<tr>
												<td>紧急联系方式：</td>
												<td><input type="text" name="carPubInfo.urgentContact" id="emergencyTelephone" /></td>
											</tr>
											<!-- 车源信息结束 -->
										</table>
										<!-- <input type="submit" value="发&nbsp;布" class="submit_button"> -->
										<input type="button" name="submit_button" id="submit_button"
											value="发&nbsp;布" class="submit_button" />
									</form>
								</s:else>

							</div>
							
							<div id="blank" style="height:40px;">
								
							</div>
							
							<div id="my_offline_cars_div" class="form_wrap clearfix">
								<s:if test="myOfflineCarPubInfoModelList.size() > 0">
									<div style="font-size:15px;">
										已下线的车源信息：
									</div>
									<form id="my_offline_cars_form" method="post">
										<table id="my_offline_cars_table">
											<tr style="background-color: silver;">
												<th>序号</th>
												<th>车牌号</th>
												<th>运载路线</th>
												<th>发车区间</th>
												<th>可载数量</th>
												<th>联系方式</th>
												<th>状态</th>
												<th>操作</th>
					        				</tr>
					        				
					        				<s:iterator value="myOfflineCarPubInfoModelList" id="myInfo" status="st">
					        					<tr>
					        						<td><s:property value="#st.index+1" /></td>
					        						<td><s:property value="#myInfo.carNumber" /></td>
					        						<td width="140px">
					        							<s:iterator value="#myInfo.carRouteList" id="route" status="st1">
					        								<s:property value="#st1.index+1"/>
					        								<huoyun:regionSelect provinceValue="${route.startProvince }" cityValue="${route.startCity }" townValue="${route.startTown }" type="view"/>
					        								&rarr;
					        								<huoyun:regionSelect provinceValue="${route.endProvince }" cityValue="${route.endCity }" townValue="${route.endTown }" type="view"/>
					        								<br>
					        							</s:iterator>
					        						</td>
					        						<td width="130px">
					        							始：<huoyun:dateFormat date="${myInfo.starttime }" dateFormat="yyyy-MM-dd HH:mm"/><br>
					        							终：<huoyun:dateFormat date="${myInfo.endtime }" dateFormat="yyyy-MM-dd HH:mm"/>
					        						</td>
					        						<td><s:property value="#myInfo.loadAmount" /><huoyun:customSelect mode="measureType" value="${myInfo.unit }" type="view"/>
					        						<td>
					        							默认：<s:property value="#myInfo.defaultContact" /><br>
					        							紧急：<s:property value="#myInfo.urgentContact" />
					        						</td>
					        						<td>未上线</td>
					        						<td><a href="<%=request.getContextPath()%>/car/redirectEditCarInfo.action?id=${myInfo.id}">修改并重新发布</a></td>
					        					</tr>
					        				</s:iterator>
										</table>
									</form>
								</s:if>
								<s:else>
									（温馨提示：当前没有未上线的车源信息）
								</s:else>
							</div>
						</div>
						
						<!-- 已下线的车源 -->
						<div>
							
						</div>
					</div>
				</div>
				<!-- 中间 -->
			</div>
			<!--中间-->
		</div>
	</div>
	<div>
		<jsp:include page="../footer.jsp"></jsp:include>
	</div>
</body>
</html>
